package com.sq.partner.manager.dao.impl;

import com.sq.partner.manager.dao.CommissionDao;
import com.sq.partner.manager.mybatis.model.ZJYDCommApplication;
import com.sq.partner.manager.mybatis.model.ZJYDCommPolicy;
import com.sq.partner.manager.util.Page;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

@Repository
public class CommissionDaoImpl extends BaseDaoImpl implements CommissionDao {


    @Override
    public Page<ZJYDCommApplication> queryApplicationPage(Map map) throws Exception {

        List queryList = queryList("queryApplicationPage", map);
        Long queryCount = (Long)query("queryApplicationCount", map);

        Page<ZJYDCommApplication> page = new Page<ZJYDCommApplication>();
        page.setData(queryList);
        page.setTotal(queryCount);
        return page;
    }

    @Override
    public Page queryPolicyPageByApplyId(Page page) throws Exception {

        List queryList = queryList("queryPolicyPage", page.getMap());
        Long queryCount = (Long)query("queryPolicyCount", page.getMap());

        page.setData(queryList);
        page.setTotal(queryCount);
        return page;
    }

    @Override
    public String downloadNotApply(String applyId) throws Exception {
        String url = (String) query("downloadNotApply",applyId);
        return url;
    }

    @Override
    public ZJYDCommPolicy queryToCheck(String policyId) throws Exception {
        return (ZJYDCommPolicy) query("queryToCheck",policyId);
    }

    @Override
    public void saveCheckPolicy(ZJYDCommPolicy zjydCommPolicy) throws Exception {
        update("saveCheckPolicy",zjydCommPolicy);
    }

    @Override
    public String downloadApply(String applyId) throws SQLException {
        return (String) query("downloadApply",applyId);
    }
}
